//<![CDATA[
String.prototype.trim = function () {
	return this.replace(/^\s*/g, "").replace(/\s*$/g, "");
}

function getFindFormObject(caller) {
	for (var obj = caller; obj; obj = obj.parentNode) {
		if (obj.nodeName == "FORM")
			return obj;
	}
	return null;
}

function getSpellcheck(caller, entryId_TMP, content, flag) {

	if(flag){
		var checkByID = document.getElementById("comment_" + entryId_TMP);
		var oForm = getFindFormObject(caller);
		if (!oForm) return false;
		if (!entryId_TMP || entryId_TMP == "") entryId_TMP = 0;

		for (i=0; i<oForm.elements.length; i++) {
			if (oForm.elements[i].disabled == true)
				continue;	
			if (oForm.elements[i].tagName.toLowerCase() == "textarea") {
					content = oForm.elements[i].value;
			}
		}
	}

	if(content.trim() == "") {
		alert("본문을 입력해 주세요"); 
		return false;
	}
	getSpellCheckProcess(content)
}

function getSpellWindow(content) {
	var _width	= 577;
	var _height = 350;
	var _left	= screen.width/2-_width/2;
	var _top	= screen.height/2-_height/2;

	var spellWin = window.open("about:blank", "spellWin", "width="+_width+", height="+_height+", left="+_left+",top="+_top+", scrollbars=yes,	status=no");
	spellWin.document.write("<html><title>우리말 맞춤법 검사 결과</title>");
	spellWin.document.write("<body style='margin:5px;'>");
	spellWin.document.write(content);
	spellWin.document.write("</body></html>");

	try {spellWin.document.close();}
	catch(e) { }
	try {spellWin.document.focus();}
	catch(e) { }
}

function getSpellCheckProcess(content) {
	var queryString	= "content=" + content;
	var spellDiv = document.getElementById("SpellView");

	var request = new HTTPRequest("POST", blogURL_USC + "/plugin/spellcheck");
	request.async = false;
	request.onSuccess = function () {
		getSpellWindow(this.getText("/response/spellContent"));
	}
	request.onError = function() {
		getSpellWindow("맞춤법 검사를 하지 못했습니다.");
	}
	request.send(queryString);
}
//]]>